'use strict';

/* Controllers */
// signin controller
app.controller('SigninFormController', ['$scope', '$http', '$state', 'AuthService',
    function ($scope, $http, $state, AuthService) {
        $scope.user = {};
        $scope.authError = null;
        $scope.login = function () {
            AuthService.login($scope.user.email, $scope.user.password)
                .then(function (response) {
                    if (response.success) {
                        $state.go('app.home');
                    } else {
                        $scope.authError = '用户或密码不正确';
                    }
                }, function (ex) {
                    $scope.authError = 'Server Error';
                });
        };
    }])
